export class TimeUtils {
  private static instance: TimeUtils

  static getInstance(): TimeUtils {
    if (TimeUtils.instance) {
      TimeUtils.instance = new TimeUtils()
    }
    return TimeUtils.instance
  }

  private constructor() {
  }

  /**
   * 获取当前时间戳
   */
  getCurrentTimeMillis(): number {
    return Date.now()
  }

  /**
   * 获取日期时间戳
   */
  getTimeMillis(time: string): number {
    return Date.parse(time)
  }

  /**
   * 获取年月日
   */
  getYearMonthDay(time: number): string {
    let date = new Date(time)
    return date.getFullYear() + '年' + (date.getMonth() + 1) + '月' + date.getDate() + '日'
  }

  /**
   * 获取年月日 时分秒
   */
  getYearMonthDayHourMuteSecond(time: number): string {
    let date = new Date(time)
    return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' '
    + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds()
  }
}